package com.bytedance.lucky.aspect;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author zouyaowen
 * @date 2021-02-12 21:00
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResponse<T> implements Serializable {
    private static final Integer SUCCESS_STATUS = 200;
    private static final String SUCCESS_MESSAGE = "success";
    /**
     * 响应状态码
     */
    private Integer status;
    /**
     * 响应信息
     */
    private String message;
    /**
     * 接口请求时间
     */
    private LocalDateTime qt;
    /**
     * 接口响应时间
     */
    private LocalDateTime rt;
    /**
     * 响应数据
     */
    private T data;

    public static CommonResponse<Object> success() {
        CommonResponse<Object> res = new CommonResponse<>();
        res.setStatus(SUCCESS_STATUS);
        res.setMessage(SUCCESS_MESSAGE);
        return res;
    }
}
